#ifndef NETWORK_DATAGRAM_SOCKET_H
#define NETWORK_DATAGRAM_SOCKET_H

#include <winsock2.h>

#include "base/types.h"

namespace network {

class DatagramPacket;
class SocketAddress;
    
class DatagramSocket {
public:
    DatagramSocket();
    ~DatagramSocket();

    inline bool IsValid() const { return socket_ == INVALID_SOCKET; }

    void Bind(const SocketAddress& address);
    void Send(const SocketAddress& address, const DatagramPacket& packet);
    void Receive(const SocketAddress& address, DatagramPacket& packet);

private:
    int SetOption(int level, int name, unsigned long value);

    SOCKET socket_;

    DISALLOW_COPY_CONSTRUCTORS(DatagramSocket);
};

} // namespace network

#endif // NETWORK_DATAGRAM_SOCKET_H
